<?php

namespace Encore\WangEditorPro;

use Encore\Admin\Admin;
use Encore\Admin\Form;
use Illuminate\Support\ServiceProvider;

class WangEditorProServiceProvider extends ServiceProvider
{
    /**
     * {@inheritdoc}
     */
    public function boot(WangEditorPro $extension)
    {
        if (! WangEditorPro::boot()) {
            return ;
        }

        if ($views = $extension->views()) {
            $this->loadViewsFrom($views, 'laravel-admin-wangEditorPro');
        }

        if ($this->app->runningInConsole() && $assets = $extension->assets()) {
            $this->publishes(
                [$assets => public_path('vendor/laravel-admin-ext/wang-editor-pro')],
                'laravel-admin-wangEditorPro'
            );
        }

        $this->app->booted(function () {
            WangEditorPro::routes(__DIR__.'/../routes/web.php');
        });

        Admin::booting(function () {
            Form::extend('editorPro', EditorPro::class);
        });
    }
}